<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <script>
    // news 新闻
    fetch("http://ajax-api.itheima.net/api/news")
      .then((res) => res.json())
      .then(({ data }) => {
        console.log(data);
      });
    // login 登录
    fetch("http://ajax-api.itheima.net/api/login", {
      method: "POST",
      headers: {
        "content-type": "application/json",
      },
      body: JSON.stringify({
        username: "admin",
        password: "123456",
      }),
      // 结果的获取，直接调用函数
    })
      .then((res) => res.json())
      .then((res) => {
        console.log(res);
      });
    // robot 机器人
    fetch("http://ajax-api.itheima.net/api/robot?spoken=王磊好帅")
      .then((res) => res.json())
      .then((res) => {
        console.log(res);
      });
  </script>
</body>

</html>